package com.easy.service.impl;

import com.easy.bean.Production_order;
import com.easy.mapper.ProductionOrderDao;
import com.easy.service.ProductionOrderService;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductionOrderServiceImpl implements ProductionOrderService {

    @Autowired
    ProductionOrderDao productionOrderDao;

    @Override
    public Production_order add(Production_order order) {
        productionOrderDao.add(order);
        return productionOrderDao.one(order.getId());
    }

    @Override
    public int del(Integer id) {
        return productionOrderDao.del(id);
    }

    @Override
    public Production_order edit(Production_order order) {
        productionOrderDao.edit(order);
        return productionOrderDao.one(order.getId());
    }

    @Override
    public List<Production_order> all(String status) {
        return productionOrderDao.all(status);
    }

    @Override
    public Production_order one(Integer id) {
        return productionOrderDao.one(id);
    }

    @Override
    public List<Production_order> page(Page page, Production_order order) {
        int count = productionOrderDao.pageCount(order);
        List<Production_order> data = productionOrderDao.page(page, order);
        page.setCount(count);
        page.setData(data);
        return data;
    }
}